#include <SFML/Graphics.hpp>
#include <iostream>
using std::cout;
using std:: endl;
int main()
{
    sf::RenderWindow window(sf::VideoMode(500, 500), "SFML works!");
    sf::CircleShape shape(10.f);
    shape.setFillColor(sf::Color::Green);

    float accely = 1;
    float accelx = 1;
    int prevmovex = 2;
    int prevmovey = 2;

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }
        sf::Vector2f position = shape.getPosition();
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::A) && position.x > 0)
        {
            if(prevmovex == 0)
            {
                accelx = accelx+.01;
                if(accelx > 10)
                {
                    accelx = 10;
                }

            }
            else
            {
                accelx = 1;
            }
            shape.move(-.01*accelx,0);
            prevmovex = 0;
        }
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::D) && position.x < 480)
        {
            if(prevmovex == 1)
            {
                accelx = accelx+.01;
                if(accelx > 10)
                {
                    accelx = 10;
                }
            }
            else
            {
                accelx = 1;
            }
            shape.move(.01*accelx,0);
            prevmovex = 1;
        }
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::W) && position.y > 0)
        {
            if(prevmovey == 0)
            {
                accely = accely+.01;
                if(accely > 10)
                {
                    accely = 10;
                }

            }
            else
            {
                accely = 1;
            }
            shape.move(0, -.01*accely);
            prevmovey = 0;
        }
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::S) && position.y < 480)
        {
            if(prevmovey == 1)
            {
                accely = accely+.01;
                if(accely > 10)
                {
                    accely = 10;
                }

            }
            else
            {
                accely = 1;
            }
            shape.move(0, .01*accely);
            prevmovey = 1;
        }
        window.clear();
        window.draw(shape);
        window.display();
    }

    return 0;
}
